package com.jingdianjichi.club.oss.config;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * minio连接 配置类
 * @author 86156
 * @version 1.0
 * @date 2024-10-25 8:52
 */
@Configuration
@RefreshScope
public class MinioConfig {

    /**
     * minio连接的Url
     */
    @Value("${minio.url}")
    private String url;

    /**
     * minio连接的账户名称
     */
    @Value("${minio.accessKey}")
    private String accessKey;

    /**
     * minio连接的密码
     */
    @Value("${minio.secretKey}")
    private String secretKey;

    /**
     * minio的client
     * @return
     */
    @Bean
    @RefreshScope
    public MinioClient getMinioClient() {
        return MinioClient.builder().endpoint(url).credentials(accessKey,secretKey).build();
    }
}
